﻿<?php
include "../../templates/db/db.php";




$id = $_GET['id'];
$comment = strip_tags(addslashes($_POST['comment']));
$date = time();
$who_added = $_SESSION['username'];

echo $comment;

$sel_id = mysql_query("SELECT * FROM cat_t WHERE id='".$id."'");
$row = mysql_fetch_assoc($sel_id);

if($_POST['submit']) {
if(strlen($comment) > 3) {
$ins = "INSERT INTO com_t(`who_added`, `comment`, `date`, `title_t`) 
VALUES('".$who_added."', '".$comment."', '".$date."', '".$row['t_title']."')";
$ins_q = mysql_query($ins) or die(mysql_error());
?>
<script type='text/javascript'>
	alert('Успешно записан коментар!');
	window.close();
</script>
<?php
} else {
?>
<script type='text/javascript'>
	alert('Коментарът трябва да бъде по дълъг от 3 символа!');
	window.close();
</script>
<?php
}
}